package com.example.webdome.config;

import com.example.webdome.interceptor.Interceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
@Slf4j
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private Interceptor interceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("添加拦截器");
        registry.addInterceptor(interceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/users/**"
                        ,"/spider/getIcon"
                        ,"/emails/**"
                        ,"/error"
                        ,"/static/**"
                        ,"/*.html"
                        ,"/*.js"); // 这里可以排除不需要进行Token验证的路径
    }

}
